﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Mvc;
using Entity.ProjectEnt;
using ZFine.Application.Project;
using ZFine.Application.SystemManage;
using ZFine.Code;
using ZFine.Domain.Entity;
using ZFine.Web;

namespace Logiv.WEB.Areas.Project.Controllers
{
    public class CarTypeController : BaseController
    {

        private CarTypeApp serverApp = new CarTypeApp();
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Form()
        {
            return View();
        }


        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJson(Pagination pagination, string keyword)
        {
            try
            {
                var data = new
                {
                    rows = serverApp.GetList(pagination, keyword),
                    total = pagination.total,
                    page = pagination.page,
                    records = pagination.records
                };
                return Content(data.ToJson());

            }
            catch (Exception ex)
            {
                return null;
            }

        }
        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetFormJson(string keyValue)
        {
            var data = serverApp.GetForm(keyValue);
            return Content(data.ToJson());
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [HandlerAuthorize]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteForm(string keyValue)
        {
            int result = serverApp.DeleteForm(keyValue);
            if (result == -1)
            {
                return Warn("请选择要删除的项");
            }
            else if (result == -2)
            {
                return Warn("没有权限对此进行删除");
            }
            return Success("删除成功。");
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateInput(false)]
        public ActionResult SubmitForm(CarTypeEntity NewsEntity, string keyValue)
        {
            int result = serverApp.SubmitForm(NewsEntity, keyValue);
            if (result == -1)
            {
                return Error("找不到对象");
            }
            else
            {
                return Success("操作成功。");
            }
        }
    }
}